home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: HELP on string functions ????
- Date: Fri, 15 Mar 96 23:31:06 GMT
- Organization: none
- Message-ID: <826932666snz@genesis.demon.co.uk>
- References: <826150130.AA00176@escan.demon.co.uk>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!genesis.demon.co.uk
-
- In article <826150130.AA00176@escan.demon.co.uk>
- bill@escan.demon.co.uk "Bill Birrell" writes:
-
- > What's wrong with:-
- >
- > char *p;
- > *p='\0'; ?
-
- This defines an unilitialised pointer and then tries to dereference it which
- is illegal. The problem is that while space has been allocated to hold a
- pointer, no space has been allocated to hold a char and the pointer doesn't
- point to anywhere valid.
-
- > alternatively you could write a funtion:-
- >
- > void strset(char *p, char q)
- > {
- > *p=q;
- > }
-
- This encounters the same problem if you don't pass it a valid pointer to
- a character object.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-